package com.example.user.coolrun.runnershign;

import android.content.Intent;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.example.user.coolrun.R;

public class PeopleActivity extends AppCompatActivity {

    public static final String PEOPLE_NAME = "people_name";
    public static final String PEOPLE_IMAGE_ID = "people_image_id";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_people);
        Intent intent = getIntent();
        final String peopleName = intent.getStringExtra(PEOPLE_NAME);
        int peopleImageId = intent.getIntExtra(PEOPLE_IMAGE_ID,0);
//        Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
        CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout)findViewById(R.id.collapsing_toolbar);
        ImageView peopleImageView = (ImageView)findViewById(R.id.people_image_view);

        if (peopleName.equals("小强强")) {
            TextView peopleContentText = (TextView)findViewById(R.id.people_content_text);
            peopleContentText.setText("纷繁浮华的现代生活，人们最需要的便是这份淳朴与真实，清水出芙蓉，天然去雕饰，浮云渐起之时，你是否愿意回头多看我一眼。");;
        }
        if (peopleName.equals("黑头强")){
            TextView peopleContentText = (TextView)findViewById(R.id.people_content_text);
            peopleContentText.setText("我是一颗认真的卤蛋！");
        }
        if (peopleName.equals("光头强")){
            TextView peopleContentText = (TextView)findViewById(R.id.people_content_text);
            peopleContentText.setText("她——圆圆的脸蛋柔和却又不失个性，细长的双眼、紧皱的眉头彰显着他的严谨与认真，锃光瓦亮的脑门发出了坚定的声音：学Java的女人绝不认输！");
        }
        if (peopleName.equals("真的强")){
            TextView peopleContentText = (TextView)findViewById(R.id.people_content_text);
            peopleContentText.setText("在我心中我是一个炫酷的强者，在你眼中我是一只蠢萌的二哈，真真假假，假假真真，只要你愿意，我便一直陪着你~\n");
        }
        if (peopleName.equals("铁头强")){
            TextView peopleContentText = (TextView)findViewById(R.id.people_content_text);
            peopleContentText.setText("丢掉美白，丢掉滤镜，我就是我，是颜色不一样的烟火，地球不爆炸，我就不关机；宇宙不重启，我就不休息，风里雨里节日里，你轻唤我我便带着微笑奔向你。");
        }

//        setSupportActionBar(toolbar);
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null){
            actionBar.setDisplayHomeAsUpEnabled(true);
        }
        collapsingToolbarLayout.setTitle(peopleName);
        Glide.with(this).load(peopleImageId).into(peopleImageView);
//        String peopleContent = generatePeopleContent(peopleName);
//        peopleContentText.setText(peopleContent);

        FloatingActionButton fab = (FloatingActionButton)findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v){
                Toast.makeText(PeopleActivity.this, "保存装扮成功！",Toast.LENGTH_SHORT).show();
                if (peopleName=="小强强")
                    Player.setRenwuzhonglei(1);
                if (peopleName.equals("黑头强"))
                    Player.setRenwuzhonglei(2);
                if (peopleName.equals("光头强"))
                    Player.setRenwuzhonglei(3);
                if (peopleName.equals("真的强"))
                    Player.setRenwuzhonglei(4);
                if (peopleName.equals("铁头强"))
                    Player.setRenwuzhonglei(5);
                finish();

            }
        });
    }


    private String generatePeopleContent(String peopleName){
        StringBuilder peopleContent = new StringBuilder();
        for(int i = 0; i < 500; i++){
            peopleContent.append(peopleName);
        }
        return peopleContent.toString();
    }


    public boolean onOptionItemSelected(MenuItem item){
        switch (item.getItemId()){
            case android.R.id.home:
                finish();
                return true;
        }
        return super.onOptionsItemSelected(item);
    }
}



